#include <stdio.h>
#include <string.h>
#include <stack>
#include <iostream>
using namespace std;

int main() {
	stack <int> x;
	int s[100];
	int i, n;
	for (i = 0;; i++) {
		scanf("%d", &s[i]);
		if (s[i] == 0)

			break;
		x.push(s[i]);
		n = i;
	}
	for (i = 0; i <= n; i++) {
		printf("%d ", x.top());
		x.pop();
	}
	return 0;
}